home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20000824-20010305 / 000382_news@columbia.edu _Sat Mar 3 20:49:58 2001.msg < prev    next >
Internet Message Format  |  2020-01-01  |  6KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by fozimane.cc.columbia.edu (8.9.3/8.9.3) with ESMTP id UAA20706
  4.     for <kermit.misc@cpunix.cc.columbia.edu>; Sat, 3 Mar 2001 20:49:58 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id UAA15057
  7.     for kermit.misc@watsun.cc.columbia.edu; Sat, 3 Mar 2001 20:40:36 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: Paul Nestler <prnestler@aol.com>
  10. Subject: Re: FTP - loops and parameters for multifile reading
  11. Date: Sat, 03 Mar 2001 20:43:09 -0500
  12. Organization: Posted via Supernews, http://www.supernews.com
  13. Message-ID: <3AA19DAD.377BC1A9@aol.com>
  14. To: kermit.misc@columbia.edu
  15.  
  16. Thanks for the reponse.
  17.  
  18. You have provided an amazing amount of detail.  However, it appears your
  19. example is for the new FTP client you referred to and not for the standard FTP
  20. which comes with AIX 3.2.5 or 4.x.
  21.  
  22. Am I correct?  Or should your example work with the standard FTP program on
  23. AIX?
  24.  
  25. Frank da Cruz wrote:
  26.  
  27. > In article <3AA06BF9.7F392836@aol.com>,
  28. > Paul Nestler  <prnestler@aol.com> wrote:
  29. > : Does anyone know how to put ftp inside a loop?  Say, a loop that
  30. > : generates a list of filenames to download?
  31. > :
  32. > : Here's the background:
  33. > : I have a problem connection I am dealing with.  When transferring a
  34. > : number of files using mget in ftp, the connection hangs and aborts.  The
  35. > : point at which the ftp session hangs varies from one session to the
  36. > : next, but so far has always allowed me to transfer a few files before it
  37. > : hangs.
  38. > :
  39. > : I looked at the man page for ftp.  The man page discusses a looping
  40. > : feature and the ability to pass a parameter (from the calling script I
  41. > : suppose).  Unfortunately, the man page does not show an example nor does
  42. > : it describe the usage in any useable detail.
  43. > :
  44. > : The man page gave me the notion I should be able to put the ftp inside a
  45. > : loop and pass the name of a file to get from the remote host.  Perhaps
  46. > : there is someway of putting the ftp inside an awk script.
  47. > :
  48. > Let's see how we would do this with the new scriptable C-Kermit FTP
  49. > client.  Let's assume an anonymous login, though it need not be, and that
  50. > the files are to be transferred in binary mode, and that the filenames
  51. > are file1 through file5:
  52. >
  53. >     while true {
  54. >         ftp open somehost.com /anonymous
  55. >         if fail {
  56. >             Can't reach host           ;  Can't make connection
  57. >             sleep 10*60                ;  Wait 10 minutes and try again
  58. >             continue
  59. >         }
  60. >         ftp cd somedirectory
  61. >         if fail {
  62. >             exit 1 Fatal - can't CD to somedirectory on host
  63. >         }
  64. >         while true {
  65. >             ftp mget /binary /recover file1 file2 file3 file4 file5
  66. >             if success goto done        ;  All files downloaded: done.
  67. >             if not \v(ftp_connected) {  ;  Failed - why?
  68. >                 ftp close               ;  Connection closed
  69. >                 break                   ;  Go back and make a new one
  70. >             }
  71. >             ; Connection still open - try MGET again.
  72. >             echo "Download failed - trying again in 20 seconds..."
  73. >             sleep 20
  74. >             continue
  75. >         }
  76. >     }
  77. >     :done
  78. >     ftp bye                             ;  Disconnect from server
  79. >     exit 0                              ;  Exit successfully
  80. >
  81. > This is a very straightforward example, with hardwired host, directory,
  82. > and filenames.  Of course these could also be variables that could be
  83. > resolved in various ways, e.g. from command-line options, with interactive
  84. > prompting, or from a file.
  85. >
  86. > The loop connects to the host, cd's to the desired directory, and requests
  87. > the files in binary mode.  Each step is checked for failure and is retried
  88. > until it succeeds.  Of course you could use a counted loop rather than an
  89. > infinite loop if you wished, and you could use different sleep intervals
  90. > or none at all.
  91. >
  92. > In this example, failure to connect results in a 10-minute pause (assuming
  93. > the host is down or unavailable) and then a loop restart.  You could make
  94. > it do anything else that might be more appropriate.
  95. >
  96. > The magic command is MGET /BINARY /RECOVER <file-list>.  For each file in
  97. > the list:
  98. >
  99. >  . If the file does not exist on the client, it is downloaded; otherwise:
  100. >
  101. >  . If a file of the same name exists on the client, the client requests
  102. >    the host file's size and modification date-time; if the date-time and
  103. >    size are the same, the file is skipped; otherwise:
  104. >
  105. >  . If the date-time is later, the file is downloaded, overwriting the
  106. >    client's copy (which is backed up for safety); otherwise:
  107. >
  108. >  . If the size is greater, the excess part of the host file is downloaded
  109. >    and appended to the client file.
  110. >
  111. > The MGET command is in an inner loop, which retries the MGET command as
  112. > long as it fails and the connection is open.  If MGET fails because the
  113. > connection was closed, the outer loop is continued and a new connection is
  114. > made.  Thus no file is transferred more than once, and if a transfer fails
  115. > in the middle of a file, it is resumed from the point of failure next time
  116. > through the loop.
  117. >
  118. > For more information about the C-Kermit FTP client, see:
  119. >
  120. >   http://www.columbia.edu/kermit/ftpclient.html
  121. >
  122. > And for a tutorial on scripting the new FTP client, see:
  123. >
  124. >   http://www.columbia.edu/kermit/ftpscript.html
  125. >
  126. > The new FTP client is still in prerelease testing but should be perfectly
  127. > usable, and should be formally released soon.   A prebuilt binary for AIX
  128. > 4.3.2 can be downloaded from C-Kermit 7.1 site:
  129. >
  130. >   http://www.columbia.edu/kermit/ck71.html
  131. >
  132. > as well as the source code and binaries for many other platforms.
  133. >
  134. > - Frank
  135.